package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  剧集壳超前配置
 */
@Data
@Entity
@Table(name = "advance_programs")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdvancePrograms implements Serializable {

    private static final long serialVersionUID = 1526453233200314193L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "ADVANCE_PROGRAMS_SEQ")
    @SequenceGenerator(name = "ADVANCE_PROGRAMS_SEQ", allocationSize = 1, sequenceName = "ADVANCE_PROGRAMS_SEQ")
    private Long id;

    /**
     * <b>Fields</b> prdContId : 壳节目id
     */
    @Column(name = "prd_cont_id")
    private Long prdContId;

    /**
     * <b>Fields</b> contentId : 壳内容id
     */
    @Column(name = "content_id")
    private Long contentId;

    /**
     * <b>Fields</b> advanceContId : 子集节目id
     */
    @Column(name = "advance_cont_id")
    private Long advanceContId;

    /**
     * <b>Fields</b> advanceSerialSequence : 集号or序号
     */
    @Column(name = "advance_serial_sequence")
    private Integer advanceSerialSequence;

    /**
     * <b>Fields</b> advanceStartTime : 开始时间
     */
    @Column(name = "advance_start_time")
    private String advanceStartTime;

    /**
     * <b>Fields</b> advanceEndTime : 结束时间
     */
    @Column(name = "advance_end_time")
    private String advanceEndTime;

    /**
     * <b>Fields</b> authorityLimit : 鉴权限制
     */
    @Column(name = "authority_limit")
    private String authorityLimit;

    /**
     * <b>Fields</b> remarks : 备注
     */
    @Column(name = "REMARKS")
    private String remarks;

    /**
     * <b>Fields</b> createdBy : 创建人
     */
    @Column(name = "created_by")
    private String createdBy;

    /**
     * <b>Fields</b> createdTime : 创建时间
     */
    @Column(name = "created_time")
    private String createdTime;

    /**
     * <b>Fields</b> updatedBy : 更新人
     */
    @Column(name = "updated_by")
    private String updatedBy;

    /**
     * <b>Fields</b> updatedTime : 更新时间
     */
    @Column(name = "updated_time")
    private String updatedTime;

    /**
     * <b>Fields</b> del : 删除列 是否删除 1:是 0:否
     */
    @Column(name = "del")
    private Integer del;

    public static void putTimeAndUser(AdvancePrograms advancePrograms) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = formatter.format(currentTime);
        if(advancePrograms.getId() == null){
            advancePrograms.setCreatedBy(CurrentUser.currUserName());
            advancePrograms.setCreatedTime(dateString);
        }
        advancePrograms.setUpdatedBy(CurrentUser.currUserName());
        advancePrograms.setUpdatedTime(dateString);
    }
}
